package com.zzs.library.service.impl;

import com.zzs.library.nosql.elasticsearch.document.EsBook;
import com.zzs.library.nosql.elasticsearch.repository.EsBookRepository;
import com.zzs.library.service.EsBookService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

/**
 * @Author ZechariahZheng
 * @Date 2020/1/7 9:49
 * @Version 1.0
 * @description 小说搜索管理Service实现类
 */
@Service
public class EsBookServiceImpl implements EsBookService {
    private static final Logger LOGGER = LoggerFactory.getLogger(EsBookServiceImpl.class);
    @Autowired
    private EsBookRepository bookRepository;

    @Override
    public Page<EsBook> search(String keyword, Integer pageNum, Integer pageSize) {
        Pageable pageable= PageRequest.of(pageNum, pageSize);
        return bookRepository.findByNameOrAuthOrBrief(keyword, keyword, keyword, pageable);
    }
}
